<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
	<link rel="stylesheet" type="text/css" href="../../css/api.css" />
	<link rel="stylesheet" type="text/css" href="../../css/common.css" />
	<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
  <link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
  <title>学术</title>
  <style>
		html, body {width: 100%;min-height: 100%;background: #f0f0f0;}
    .h20 {height: 0.5rem;background: #f0f0f0;}

    .xsContent {
    }
    .xsContent .aui-list-item-media {
      width: 6.5rem;
    }
    .xsContent .aui-list-item .aui-list-item-title {
      color: #333;
      line-height: 1.2rem;
      font-size: 0.8rem;
    }
    .xsContent .aui-list-item .aui-info .aui-info-item {
      color: #999;
      font-size: 0.7rem;
    }
    .xsContent .aui-list-item .aui-info {
      width: 100%;
      display: block;
    }
    .xsContent .aui-list-item .aui-info-item span {
      color: #ffb451;
      float: right;
    }
    .xsContent .aui-media-list .aui-list-item-inner {
      display: -webkit-box;
      display: -webkit-flex;
      display: flex;
      -webkit-box-orient: vertical;
      box-orient: vertical;
      -webkit-flex-direction: column;
      flex-direction: column;
      -webkit-box-pack: justify;
      -webkit-justify-content: space-between;
      justify-content: space-between;
      -webkit-box-align: start;
      -webkit-align-items: flex-start;
      align-items: flex-start;
    }
    .itemIco {
      width: 100%;
      height: 4rem;
    }
    .xsContent {
      min-height: calc(100vh - 65px)
    }
	</style>
</head>
<body>
<section class="aui-refresh-content">
<div id="app" v-cloak>
  <div class="aui-content xsContent">
    <ul class="aui-list aui-media-list">
      <li class="aui-list-item" v-for="item in newsList" @click="openDetail('活动详情', item.id)">
        <div class="aui-media-list-item-inner">
          <div class="aui-list-item-media">
            <!-- <img :src="item.images" alt="" v-if="item.images && item.images != ''">
            <img src="../../image/banner1.jpg" alt="" v-else> -->
            <div v-if="item.images && item.images != ''" class="itemIco" :style="'background: url('+ item.images +') center/cover no-repeat'"></div>
            <div v-else class="itemIco" style="background: url(../../image/banner1.png) center/cover no-repeat"></div>
          </div>
          <div class="aui-list-item-inner">
            <div class="aui-list-item-text">
              <div class="aui-list-item-title">{{item.title}}</div>
            </div>
            <div class="aui-info aui-margin-t-5" style="padding:0">
              <div class="aui-info-item" style="font-size: 0.6rem">{{item.apply_date}} 开始<span>{{item.applyCount}}人已报名</span></div>
            </div>
          </div>
        </div>
      </li>
    </ul>
  </div>
</div>
</section>
</body>
<script src="../../script/aui-tab.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript" src="../../script/utils.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/aui-scroll.js"></script>
<script src="../../script/aui-pull-refresh.js"></script>
<script>

apiready = function() {
    var app = new Vue({
      el: '#app',
      data: {
        newsList: [],
        page: 1,
        totalpage: 1
      },
      created: function() {
        var $_this = this;

        api.ajax({
          url: window.Url.getActivityList + '-1/' + $_this.page,
          timeout: 300,
        }, function(ret, err) {
            if (ret) {
                console.log(JSON.stringify(ret) );
                if (ret.data != null) {
                  $_this.totalpage = ret.data.totalpage
                  $_this.newsList = ret.data.newsList
                }

            } else {
                api.alert({ msg: JSON.stringify(err) });
            }
        })
        var scroll = new auiScroll({
  							listen:true, //是否监听滚动高度，开启后将实时返回滚动高度
  							distance:40 //判断到达底部的距离，isToBottom为true
  					},function(ret){
  						 if (ret.isToBottom) {
  							 $_this.page ++
  							 if ($_this.page > $_this.totalpage) {
  								 $_this.page = $_this.totalpage
  								 return
  							 }
  							 api.ajax({
                   url: window.Url.getActivityList + '-1/' + $_this.page,
  								timeout: 300,
  							}, function(ret, err) {
  									if (ret) {
  										 //  api.alert({ msg: JSON.stringify(ret) });
  											$_this.newsList = $_this.newsList.concat(ret.data.newsList)

  									} else {
  											api.alert({ msg: JSON.stringify(err) });
  									}
  							})
  						 }

  					})

            var pullRefresh = new auiPullToRefresh({
                container: document.querySelector('.aui-refresh-content'),
                triggerDistance: 100
            },function(ret){
                if(ret.status=="success"){
                  $_this.page = 1
                  api.ajax({
                    url: window.Url.getActivityList + '-1/' + $_this.page,
                    timeout: 300,
                  }, function(ret, err) {
                      if (ret) {
                          // api.alert({ msg: JSON.stringify(ret) });
                          setTimeout(function() {
                            if (ret.data != null) {
                              $_this.totalpage = ret.data.totalpage
                              $_this.newsList = ret.data.newsList
                              pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                            }else {
                              pullRefresh.cancelLoading(); //刷新成功后调用此方法隐藏
                            }
                          },500)


                      } else {
                          api.alert({ msg: JSON.stringify(err) });
                      }
                  })

                }
            })
      },
      methods: {
        openDetail: function (title, id) {
          api.openWin({
            name: 'activitydetails',
            pageParam: {
              name: 'activitydetails',
              title: title,
              id: id
            },
            url: './activitydetails.html',
            delay: 200,
            bounces: false
          });
        }
      },
      filters: {
        time: function (value) {
          return Number(value.split(' ')[0].split('-')[1]) + '月' + Number(value.split(' ')[0].split('-')[2]) + '日' + value.split(' ')[1]
        }
      },
      mounted:function() {
        var tab = new auiTab({
          element:document.getElementById("xsTab"),
          index:1,
          repeatClick:false
        },function(ret){
          var xsBox = document.querySelectorAll('.xsBox')
          for (var i = 0; i < xsBox.length; i++) {
            xsBox[i].style.display = 'none'
          }
          document.querySelectorAll('.xsBox')[ret.index - 1].style.display =  'block'
        });
      }
    })
  }
</script>
</html>
